package com.keyue.config;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

/**
 * @author: xms
 * @description: TODO
 * @date: 2023/10/31 16:33
 * @version: 1.0
 */

@Configuration
public class AliOssConfig implements InitializingBean {

    /**
     * oss 地址
     */
    @Value("${oss.endpoint}")
    private String endpoint;

    /**
     * 进入阿里oss获取产品key值
     */
    @Value("${oss.accessKeyId}")
    private String accessKeyId;

    /**
     * key值对应密码
     */
    @Value("${oss.accessKeySecret}")
    private String accessKeySecret;

    /**
     * 存储上传文件的容器
     */
    @Value("${oss.bucket}")
    private String bucket;

    @Value("${oss.roleArn}")
    public String roleArn;

    @Value("${oss.roleName}")
    public String roleName;

    //声明静态变量
    public static String ALIYUN_ENDPOINT;
    public static String ALIYUN_ACCESS_ID;
    public static String ALIYUN_ACCESS_KEY;
    public static String ALIYUN_BUCKET;
    public static String ALIYUN_ROLEARN;

    public static String ALIYUN_ROLENAME;

    @Override
    public void afterPropertiesSet() throws Exception {
        ALIYUN_ENDPOINT = endpoint;
        ALIYUN_ACCESS_ID = accessKeyId;
        ALIYUN_ACCESS_KEY = accessKeySecret;
        ALIYUN_BUCKET = bucket;
        ALIYUN_ROLEARN = roleArn;
        ALIYUN_ROLENAME = roleName;
    }
}
